// 获取头像
export function getAvatar (state) {
    let avatar = state.baseAvatar
    if (state.user && state.user.avatar) {
        avatar = state.user.avatar
    }
    return avatar
}

// 获取默认头像
export function defaultAvatar (state) {
    return state.baseAvatar
}

// 获取用户信息
export function getUser (state) {
    return state.user
}

// 查看是否关注了用户
export function attentionUser (state) {
    return function (id) {
        if (state.attentionUsers.length === 0) {
            return null
        } else {
            return state.attentionUsers.find(user => user.id === id)
        }
    }
}

export function attentionUsers (state) {
    return state.attentionUsers
}

export function hasPermission (state) {
    return function (name) {
        if (state.enablePermissions.length === 0) {
            return false
        } else {
            return state.enablePermissions.find(permission => permission.name === name)
        }
    }
}

export function enablePermissions (state) {
    return state.enablePermissions
}
